﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Teal.Compiler {

    
    /// <summary>
    /// 提供预定义类型的引用。
    /// </summary>
    public static partial class PredefinedTypes {

        #region 内置注解

        /// <summary>
        /// 获取预定义的 ImplicitAnnotaion 类型。
        /// </summary>
        public static TypeReference System_ImplicitAnnotation = new TypeReference(MemberType.@class) {
            name = "ImplicitAnnotation",
            baseClass = System_Object
        };

        /// <summary>
        /// 获取预定义的 DeprecatedAnnotation 类型。
        /// </summary>
        public static TypeReference System_DeprecatedAnnotation = new TypeReference(MemberType.@class) {
            name = "DeprecatedAnnotation",
            baseClass = System_Object
        };

        /// <summary>
        /// 获取预定义的 AnnotationUsageAnnotation 类型。
        /// </summary>
        public static TypeReference System_AnnotationUsageAnnotation = new TypeReference(MemberType.@class) {
            name = "AnnotationUsageAnnotation",
            baseClass = System_Object
        };

        /// <summary>
        /// 获取预定义的 FieldOffsetAnnotation 类型。
        /// </summary>
        public static TypeReference System_RunTime_FieldOffsetAnnotation = new TypeReference(MemberType.@class) {
            name = "FieldOffsetAnnotation",
            baseClass = System_Object
        };

        /// <summary>
        /// 获取预定义的 StructLayoutAnnotation 类型。
        /// </summary>
        public static TypeReference System_RunTime_StructLayoutAnnotation = new TypeReference(MemberType.@class) {
            name = "StructLayoutAnnotation",
            baseClass = System_Object
        };

        /// <summary>
        /// 获取预定义的 FixedBufferAnnotation 类型。
        /// </summary>
        public static TypeReference System_RunTime_FixedBufferAnnotation = new TypeReference(MemberType.@class) {
            name = "FixedBufferAnnotation",
            baseClass = System_Object
        };

        /// <summary>
        /// 获取预定义的 PermissionAnnotation 类型。
        /// </summary>
        public static TypeReference System_RunTime_PermissionAnnotation = new TypeReference(MemberType.@class) {
            name = "PermissionAnnotation",
            baseClass = System_Object
        };
        /// <summary>
        /// 获取预定义的 FixedBufferAnnotation 类型。
        /// </summary>
        public static TypeReference System_RunTime_CompilerGeneratedAnnotation = new TypeReference(MemberType.@class) {
            name = "CompilerGeneratedAnnotation",
            baseClass = System_Object
        };

        #endregion

    }

    /// <summary>
    /// 用于标记注解用法的注解。
    /// </summary>
    public sealed class AnnotationUsageAnnotation {

        /// <summary>
        /// 获取或设置当前注解的适用目标。
        /// </summary>
        public AnnotationTargets target;

        /// <summary>
        /// 判断或设置当前注解是否允许重复使用。
        /// </summary>
        public bool allowMultiple;

    }

    /// <summary>
    /// 表示注解的目标成员类型。
    /// </summary>
    public enum AnnotationTargets {

        /// <summary>
        /// 表示一个扩展。
        /// </summary>
        extension = MemberType.extension,

        /// <summary>
        /// 针对类。
        /// </summary>
        @class = MemberType.@class,

        /// <summary>
        /// 针对结构。
        /// </summary>
        @struct = MemberType.@struct,

        /// <summary>
        /// 针对接口。
        /// </summary>
        @interface = MemberType.@interface,

        /// <summary>
        /// 针对枚举。
        /// </summary>
        @enum = MemberType.@enum,

        /// <summary>
        /// 针对类型。
        /// </summary>
        TYPE = @class | @struct | @interface | @enum,

        /// <summary>
        /// 针对字段。
        /// </summary>
        field = MemberType.field,

        /// <summary>
        /// 针对属性。
        /// </summary>
        property = MemberType.property,

        /// <summary>
        /// 针对索引访问器。
        /// </summary>
        indexer = MemberType.indexer,

        /// <summary>
        /// 针对方法。
        /// </summary>
        method = MemberType.method,

        /// <summary>
        /// 针对构造函数。
        /// </summary>
        constructor = MemberType.constructor,

        /// <summary>
        /// 针对操作符重载函数。
        /// </summary>
        operatorOverload = MemberType.@operator,

        /// <summary>
        /// 针对函数。
        /// </summary>
        FUNCTION = method | constructor | operatorOverload,

        /// <summary>
        /// 针对类型成员。
        /// </summary>
        TYPE_MEMBER = field | property | indexer | FUNCTION,

        /// <summary>
        /// 针对所有成员。
        /// </summary>
        ALL = TYPE | TYPE_MEMBER,

    }

    /// <summary>
    /// 存储表示成员被否定的信息。
    /// </summary>
    public sealed class DeprecatedData {

        /// <summary>
        /// 获取否定后的提示信息。
        /// </summary>
        public string message;

        /// <summary>
        /// 判断当前否定是否被认为错误。
        /// </summary>
        public bool error;

        /// <summary>
        /// 表示一个暂时未解析的否定信息。
        /// </summary>
        public static readonly DeprecatedData uninitialized = new DeprecatedData();

    }

}
